;Assembler header file for CD
;written by DefMod (Dec 31 2005) on Sat Dec 31 14:01:37 2005
;Simon Middleton, Uniqueway Ltd; Jonathan Coxhead, jonathan@doves.demon.co.uk, 12 July 1995

        [       :LNOT: :DEF: CD_Hdr
        GBLS    CD_Hdr

        [       :LNOT: :DEF: Get_Types
        GBLS    Get_Types
        ]
        [       :LNOT: :DEF: Types_Hdr
Get_Types                       SETS    "GET oslib/Types.Hdr"
        |
Get_Types                       SETS    ""
        ]
        $Get_Types

        [       :LNOT: :DEF: Get_OS
        GBLS    Get_OS
        ]
        [       :LNOT: :DEF: OS_Hdr
Get_OS                          SETS    "GET oslib/OS.Hdr"
        |
Get_OS                          SETS    ""
        ]
        $Get_OS

        [       :LNOT: :DEF: Get_SCSI
        GBLS    Get_SCSI
        ]
        [       :LNOT: :DEF: SCSI_Hdr
Get_SCSI                        SETS    "GET oslib/SCSI.Hdr"
        |
Get_SCSI                        SETS    ""
        ]
        $Get_SCSI

;Symbols for constants
Error_CDBase                    *       &803400
Error_CDBadAlignment            *       &803401
Error_CDDriveNotSupported       *       &803402
Error_CDBadMode                 *       &803403
Error_CDInvalidParameter        *       &803404
Error_CDNotAudioTrack           *       &803405
Error_CDNoCaddy                 *       &803406
Error_CDNoDrive                 *       &803407
Error_CDInvalidFormat           *       &803408
Error_CDBadMinutes              *       &803409
Error_CDBadSeconds              *       &80340A
Error_CDBadBlocks               *       &80340B
Error_CDPhysicalBlockBad        *       &80340C
Error_CDDrawerLocked            *       &80340D
Error_CDWrongDataMode           *       &80340E
Error_CDChannelNotSupported     *       &80340F
Error_CDBadDeviceID             *       &803410
Error_CDBadCardNumber           *       &803411
Error_CDBadLUNNumber            *       &803412
Error_CDNoSuchTrack             *       &803413
Error_CDFaultyDisc              *       &803414
Error_CDNoSuchBlock             *       &803415
Error_CDNotSupported            *       &803416
Error_CDDriverNotPresent        *       &803417
Error_CD_SWINotSupported        *       &803418
Error_CDTooManyDrivers          *       &803419
Error_CDNotRegistered           *       &80341A
CD_LogicalBlockAddressing       *       &0
CD_RedBookAddressing            *       &1
CD_PhysicalBlockAddressing      *       &2
CD_AUDIO                        *       &0
CD_Data                         *       &1
CD_FourChannel                  *       &0
CD_TwoChannel                   *       &2
CD_ReadAudioRead                *       0
CD_ReadAudioReasonMask          *       &FF
CD_DriveStatusOK                *       &1
CD_DriveStatusBusy              *       &2
CD_DriveStatusNotReady          *       &4
CD_DriveStatusUnavailable       *       &8
CD_DriveREADY                   *       &0
CD_DriveNotReady                *       &1
CD_MultiplierDefault            *       &0
CD_MultiplierEighthSec          *       &1
CD_MultiplierQuarterSec         *       &2
CD_MultiplierHalfSec            *       &3
CD_MultiplierOneSec             *       &4
CD_MultiplierTwoSec             *       &5
CD_MultiplierFourSec            *       &6
CD_MultiplierEightSec           *       &7
CD_MultiplierSixteenSec         *       &8
CD_MultiplierThirtyTwoSec       *       &9
CD_MultiplierOneMin             *       &A
CD_MultiplierTwoMin             *       &B
CD_MultiplierFourMin            *       &C
CD_MultiplierEightMin           *       &D
CD_MultiplierSixteenMin         *       &E
CD_MultiplierThirtyTwoMin       *       &F
CD_ModeAudio                    *       &0
CD_Mode1                        *       &1
CD_Mode2Form2                   *       &2
CD_Mode2Form1                   *       &3
CD_SpeedUnchanged               *       0
CD_SpeedStandard                *       1
CD_SpeedDouble                  *       2
CD_SpeedMax                     *       255
CD_PlayToEndOfTrack             *       &FE
CD_PlayToEndOfDisc              *       &FF
CD_AudioPlaying                 *       &0
CD_AudioPaused                  *       &1
CD_AudioCompleted               *       &3
CD_AudioError                   *       &4
CD_AudioStopped                 *       &5
CD_CheckError                   *       &0
CD_CheckSense                   *       &1
CD_CheckRetry                   *       &2
CD_SupportedAudioControl        *       &7
CD_SupportedPrefetch            *       &8
CD_SupportedCloseDrawer         *       &10
CD_SupportedAudioLevel          *       &20
CD_SupportedSpeedMultiplier     *       &3FC0
CD_SupportedReadAudio           *       &4000
CD_SupportedAudioParams         *       &8000
CD_UseOldRead                   *       &40
CD_UseOldSeek                   *       &80
CD_UseOldInquiry                *       &100
CD_UseOldCapacity               *       &200
CD_UseOldReady                  *       &400
CD_UseOldStopOpen               *       &800
CD_UseOldCheck                  *       &1000
CD_UseOldStatus                 *       &2000
CD_UseOldControl                *       &4000
CD_UseOldPrefetch               *       &8000
CD_UseOldReset                  *       &10000
CD_UseReadDataProprietary       *       &20000
CD_UseReadDataScatter           *       &40000
CD_UseSeekDataProprietary       *       &80000
CD_UseSeekDataScatter           *       &100000
CD_UseSCSIOp                    *       &200000
CD_DriveTypeUnknown             *       &FFFFFFFF
CD_AudioDone                    *       &FFFFFFFF
CD_VolumeLimit                  *       65535

;Symbols for structure offsets and sizes
                                ^       0
                                #       Bits
CD_Address                      *       @

                                ^       0
                                #       Int
CD_AddressMode                  *       @

                                ^       0
CD_ControlBlock_reserved        #       5*Int
CD_ControlBlock                 *       @

                                ^       0
                                #       Byte
CD_AudioFlags                   *       @

                                ^       0
CD_VersionBlock_version_number  #       Int
CD_VersionBlock_version_string  #       256*Char
CD_VersionBlock                 *       @

                                ^       0
                                #       Int
CD_Status                       *       @

                                ^       0
                                #       Int
CD_Readiness                    *       @

                                ^       0
                                #       Int
CD_Multiplier                   *       @

                                ^       0
                                #       Int
CD_DataMode                     *       @

                                ^       0
                                #       Int
CD_Speed                        *       @

                                ^       0
CD_ParameterBlock_inactivity_timer #       CD_Multiplier
CD_ParameterBlock_retry_count   #       Int
CD_ParameterBlock_mode          #       CD_DataMode
CD_ParameterBlock_speed         #       CD_Speed
CD_ParameterBlock               *       @

                                ^       0
                                #       Int
CD_PlayToWhat                   *       @

                                ^       0
CD_EnquireAllTracksBlock_first_track #       Byte
CD_EnquireAllTracksBlock_last_track #       Byte
CD_EnquireAllTracksBlock_reserved0 #       Byte
CD_EnquireAllTracksBlock_reserved1 #       Byte
CD_EnquireAllTracksBlock_reserved2 #       Byte
CD_EnquireAllTracksBlock        *       @

                                ^       0
CD_EnquireOneTrackBlock_address #       CD_Address
CD_EnquireOneTrackBlock_audio_control #       CD_AudioFlags
CD_EnquireOneTrackBlock         *       @

                                ^       0
CD_SubChannelBlock_relative_lba #       CD_Address
CD_SubChannelBlock_absolute_lba #       CD_Address
CD_SubChannelBlock_audio_control #       CD_AudioFlags
CD_SubChannelBlock_track_number #       Byte
CD_SubChannelBlock_index_number #       Byte
CD_SubChannelBlock              *       @

                                ^       0
CD_DiscUsedBlock_block_count    #       Int
CD_DiscUsedBlock_block_size     #       Int
CD_DiscUsedBlock                *       @

                                ^       0
                                #       Int
CD_Audio                        *       @

                                ^       0
CD_InquiryBlock_i               #       36*Byte
CD_InquiryBlock                 *       @

                                ^       0
                                #       Int
CD_ErrorResponseLevel           *       @

                                ^       0
                                #       Bits
CD_Flags                        *       @

                                ^       0
                                #       Bits
CD_RegisterFlags                *       @

                                ^       0
CD_RegisterBlock_flags          #       CD_RegisterFlags
CD_RegisterBlock_registration_count #       Int
CD_RegisterBlock_drive_type_count #       Int
CD_RegisterBlock                *       @

                                ^       0
                                #       Int
CD_DriveType                    *       @

                                ^       0
                                #       Int
CD_AudioCompletion              *       @

                                ^       0
CD_VolumeBlock_volume           #       2*Int
CD_VolumeBlock                  *       @


;Symbols for SWI's and SWI reason codes
XCD_Version                     *       &61240
CD_Version                      *       &41240
   ;Exit
   ;  R0 -> version (CD_VersionBlock)

XCD_ReadData                    *       &61241
CD_ReadData                     *       &41241
   ;Entry
   ;  R0 = address_mode (CD_AddressMode)
   ;  R1 = start_address (CD_Address)
   ;  R2 = block_count (Int)
   ;  R3 = buffer (pointer to data)
   ;  R4 = size (Int)
   ;  R7 -> control (CD_ControlBlock)

XCD_SeekTo                      *       &61242
CD_SeekTo                       *       &41242
   ;Entry
   ;  R0 = address_mode (CD_AddressMode)
   ;  R1 = seek (CD_Address)
   ;  R7 -> control (CD_ControlBlock)

XCD_DriveStatus                 *       &61243
CD_DriveStatus                  *       &41243
   ;Entry
   ;  R7 -> control (CD_ControlBlock)
   ;Exit
   ;  R0 = status (CD_Status)
   ;  R1 corrupted
   ;  R2 corrupted
   ;  R3 corrupted
   ;  R4 corrupted
   ;  R5 corrupted
   ;  R6 corrupted
   ;  R7 corrupted
   ;  R8 corrupted
   ;  R9 corrupted

XCD_DriveReady                  *       &61244
CD_DriveReady                   *       &41244
   ;Entry
   ;  R7 -> control (CD_ControlBlock)
   ;Exit
   ;  R0 = ready (CD_Readiness)

XCD_GetParameters               *       &61245
CD_GetParameters                *       &41245
   ;Entry
   ;  R0 = params (pointer to CD_ParameterBlock)
   ;  R7 -> control (CD_ControlBlock)
   ;Exit
   ;  R0 corrupted
   ;  R1 corrupted
   ;  R2 corrupted
   ;  R3 corrupted
   ;  R4 corrupted
   ;  R5 corrupted
   ;  R6 corrupted
   ;  R7 corrupted
   ;  R8 corrupted
   ;  R9 corrupted

XCD_SetParameters               *       &61246
CD_SetParameters                *       &41246
   ;Entry
   ;  R0 -> params (CD_ParameterBlock)
   ;  R7 -> control (CD_ControlBlock)
   ;Exit
   ;  R0 corrupted
   ;  R1 corrupted
   ;  R2 corrupted
   ;  R3 corrupted
   ;  R4 corrupted
   ;  R5 corrupted
   ;  R6 corrupted
   ;  R7 corrupted
   ;  R8 corrupted
   ;  R9 corrupted

XCD_OpenDrawer                  *       &61247
CD_OpenDrawer                   *       &41247
   ;Entry
   ;  R7 -> control (CD_ControlBlock)

XCD_EjectButton                 *       &61248
CD_EjectButton                  *       &41248
   ;Entry
   ;  R0 = disable (Bool)
   ;  R7 -> control (CD_ControlBlock)

XCD_EnquireAddress              *       &61249
CD_EnquireAddress               *       &41249
   ;Entry
   ;  R0 = address_mode (CD_AddressMode)
   ;  R7 -> control (CD_ControlBlock)
   ;Exit
   ;  R0 = address (CD_Address)

XCD_EnquireDataMode             *       &6124A
CD_EnquireDataMode              *       &4124A
   ;Entry
   ;  R0 = address_mode (CD_AddressMode)
   ;  R1 = address (CD_Address)
   ;  R7 -> control (CD_ControlBlock)
   ;Exit
   ;  R0 = data_mode (CD_DataMode)

XCD_PlayAudio                   *       &6124B
CD_PlayAudio                    *       &4124B
   ;Entry
   ;  R0 = address_mode (CD_AddressMode)
   ;  R1 = start (CD_Address)
   ;  R2 = end (CD_Address)
   ;  R7 -> control (CD_ControlBlock)

XCD_PlayTrack                   *       &6124C
CD_PlayTrack                    *       &4124C
   ;Entry
   ;  R0 = track (Int)
   ;  R1 = play_to (CD_PlayToWhat)
   ;  R7 -> control (CD_ControlBlock)

XCD_AudioPause                  *       &6124D
CD_AudioPause                   *       &4124D
   ;Entry
   ;  R0 = pause (Bool)
   ;  R7 -> control (CD_ControlBlock)

XCD_EnquireTrack                *       &6124E
CD_EnquireTrack                 *       &4124E

CD_EnquireAllTracks             *       &0
   ;Entry
   ;  R0 = &0
   ;  R1 = info (pointer to CD_EnquireAllTracksBlock)
   ;  R7 -> control (CD_ControlBlock)

XCD_EnquireOneTrack             *       &6124E
CD_EnquireOneTrack              *       &4124E
   ;Entry
   ;  R0 = track (Int)
   ;  R1 = info (pointer to CD_EnquireOneTrackBlock)
   ;  R7 -> control (CD_ControlBlock)

XCD_ReadSubChannel              *       &6124F
CD_ReadSubChannel               *       &4124F
   ;Entry
   ;  R0 = &40
   ;  R1 = block (pointer to CD_SubChannelBlock)
   ;  R7 -> control (CD_ControlBlock)

XCD_CheckDrive                  *       &61250
CD_CheckDrive                   *       &41250
   ;Entry
   ;  R7 -> control (CD_ControlBlock)
   ;Exit
   ;  R0 = status (Bits)

XCD_DiscChanged                 *       &61251
CD_DiscChanged                  *       &41251
   ;Entry
   ;  R7 -> control (CD_ControlBlock)
   ;Exit
   ;  R0 = changed (Bool)

XCD_StopDisc                    *       &61252
CD_StopDisc                     *       &41252
   ;Entry
   ;  R7 -> control (CD_ControlBlock)

XCD_DiscUsed                    *       &61253
CD_DiscUsed                     *       &41253
   ;Entry
   ;  R0 = address_mode (CD_AddressMode)
   ;  R1 = info (pointer to CD_DiscUsedBlock)
   ;  R7 -> control (CD_ControlBlock)

XCD_AudioStatus                 *       &61254
CD_AudioStatus                  *       &41254
   ;Entry
   ;  R7 -> control (CD_ControlBlock)
   ;Exit
   ;  R0 = status (CD_Audio)

XCD_Inquiry                     *       &61255
CD_Inquiry                      *       &41255
   ;Entry
   ;  R0 = data (pointer to CD_InquiryBlock)
   ;  R7 -> control (CD_ControlBlock)

XCD_DiscHasChanged              *       &61256
CD_DiscHasChanged               *       &41256
   ;Entry
   ;  R7 -> control (CD_ControlBlock)

XCD_Control                     *       &61257
CD_Control                      *       &41257
   ;Entry
   ;  R0 = level (CD_ErrorResponseLevel)
   ;  R7 -> control (CD_ControlBlock)

XCD_Supported                   *       &61258
CD_Supported                    *       &41258
   ;Entry
   ;  R7 -> control (CD_ControlBlock)
   ;Exit
   ;  R0 = flags (CD_Flags)

XCD_Prefetch                    *       &61259
CD_Prefetch                     *       &41259
   ;Entry
   ;  R0 = address_mode (CD_AddressMode)
   ;  R1 = address (CD_Address)
   ;  R7 -> control (CD_ControlBlock)

XCD_Reset                       *       &6125A
CD_Reset                        *       &4125A
   ;Entry
   ;  R7 -> control (CD_ControlBlock)

XCD_CloseDrawer                 *       &6125B
CD_CloseDrawer                  *       &4125B
   ;Entry
   ;  R7 -> control (CD_ControlBlock)

XCD_IsDrawerLocked              *       &6125C
CD_IsDrawerLocked               *       &4125C
   ;Entry
   ;  R7 -> control (CD_ControlBlock)
   ;Exit
   ;  R0 = locked (Bool)

XCD_AudioControl                *       &6125D
CD_AudioControl                 *       &4125D
   ;Entry
   ;  R0 = &0
   ;  R1 = control (Int)
   ;  R7 -> control_block (CD_ControlBlock)

XCD_LastError                   *       &6125E
CD_LastError                    *       &4125E
   ;Exit
   ;  R0 = errnum (Int)

XCD_AudioLevel                  *       &6125F
CD_AudioLevel                   *       &4125F
   ;Entry
   ;  R7 -> control (CD_ControlBlock)
   ;Exit
   ;  R0 -> error (OS_Error)

XCD_Register                    *       &61260
CD_Register                     *       &41260
   ;Entry
   ;  R0 -> info (CD_RegisterBlock)
   ;  R1 -> driver_code (code)
   ;  R2 = driver_workspace (pointer to Void)

XCD_Unregister                  *       &61261
CD_Unregister                   *       &41261
   ;Entry
   ;  R0 -> info (CD_RegisterBlock)
   ;  R1 -> driver_code (code)

XCD_ByteCopy                    *       &61262
CD_ByteCopy                     *       &41262
   ;Entry
   ;  R1 -> source (Byte)
   ;  R2 = destination (pointer to Byte)
   ;  R3 = size (Int)

XCD_Identify                    *       &61263
CD_Identify                     *       &41263
   ;Entry
   ;  R7 -> control (CD_ControlBlock)
   ;Exit
   ;  R2 = drive_type (CD_DriveType)

XCD_ConvertToLBA                *       &61264
CD_ConvertToLBA                 *       &41264
   ;Entry
   ;  R0 = address_mode (CD_AddressMode)
   ;  R1 = address (CD_Address)
   ;Exit
   ;  R1 = new_address (CD_Address)

XCD_ConvertToMSF                *       &61265
CD_ConvertToMSF                 *       &41265
   ;Entry
   ;  R0 = address_mode (CD_AddressMode)
   ;  R1 = address (CD_Address)
   ;Exit
   ;  R1 = new_address (CD_Address)

XCD_ReadAudio                   *       &61266
CD_ReadAudio                    *       &41266
   ;Entry
   ;  R0 = address_mode (CD_AddressMode)
   ;  R1 = address (CD_Address)
   ;  R2 = block_count (Int)
   ;  R3 = buffer (pointer to data)
   ;  R4 = flags (Bits)
   ;  R7 -> control (CD_ControlBlock)
   ;Exit
   ;  R0 corrupted
   ;  R1 corrupted
   ;  R2 = drive_type (CD_DriveType)
   ;  R3 corrupted
   ;  R4 corrupted
   ;  R5 corrupted
   ;  R6 corrupted
   ;  R7 corrupted
   ;  R8 corrupted
   ;  R9 corrupted

XCD_ReadUserData                *       &61267
CD_ReadUserData                 *       &41267
   ;Entry
   ;  R0 = address_mode (CD_AddressMode)
   ;  R1 = address (CD_Address)
   ;  R2 = size (Int)
   ;  R3 = buffer (pointer to data)
   ;  R4 = offset (Int)
   ;  R7 -> control (CD_ControlBlock)
   ;Exit
   ;  R1 = last (CD_Address)
   ;  R4 = next_offset (Int)

XCD_SeekUserData                *       &61268
CD_SeekUserData                 *       &41268
   ;Entry
   ;  R0 = address_mode (CD_AddressMode)
   ;  R1 = address (CD_Address)
   ;  R2 = offset (Int)
   ;  R7 -> control (CD_ControlBlock)
   ;Exit
   ;  R1 = found (CD_Address)
   ;  R4 = offset_out (Int)

XCD_GetAudioParms               *       &61269
CD_GetAudioParms                *       &41269

XCDGetAudioParms_VolumeBlock    *       &61269
CDGetAudioParms_VolumeBlock     *       &41269
   ;Entry
   ;  R0 = &0
   ;  R1 = block (pointer to CD_VolumeBlock)
   ;  R7 -> control (CD_ControlBlock)
   ;Exit
   ;  R0 = cmp (CD_AudioCompletion)

XCD_SetAudioParms               *       &6126A
CD_SetAudioParms                *       &4126A

XCD_SCSIUserOp                  *       &6126B
CD_SCSIUserOp                   *       &4126B
   ;Entry
   ;  R0 = op (Bits)
   ;  R1 = block_size (Int)
   ;  R2 -> block (SCSI_OpBlock)
   ;  R3 = start_addr (pointer to data)
   ;  R4 = length (Int)
   ;  R5 = timeout (Int)
   ;  R7 -> control (CD_ControlBlock)
   ;Exit
   ;  R3 = next_addr (pointer to data)
   ;  R4 = undone (Int)

        ]
        END
